import { useState, useEffect } from 'react'
import axios from 'axios'

function useTitle(title) {
    const [state] = useState(100)
    document.title = title + state
}

// 逻辑复用
function usePage(url, params) {
    const [list, setList] = useState([])
    const [total, setTotal] = useState(0)
    useEffect(() => {
        axios.get(url, {
            params
        }).then(res => {
            console.log(res.data.message)
            setList(res.data.message.goods)
            setTotal(res.data.message.total)
        })
    }, [])
    return [list, total]
}

export {
    useTitle,
    usePage
}